
cc.Class({
    extends: cc.Component,

    properties: {
        gold: cc.Node, 
        goldLabel: cc.Label, 
        gameProgress: cc.ProgressBar,
        progressLabel: cc.Label, 
        skillProgress: cc.Node
    },


    onLoad () {
        this.init()
    },

    init(){
        this.goldLabel.string = 0
        this.gameProgress.progress = 1
        this.progressLabel.string = '100%'
        this.progressHp = 2000
        this.curHp = this.progressHp
    },

    getBeGold() {
        return this.gold
    },

    getlabelGold() {
        return this.goldLabel
    },

    getBeGoldWorldPos(){
       return utils.getNodePos(this.gold, game.node)
    },


    //本场获取金币
    getGold(num) {
        this.goldLabel.string = data.getGold(num)
    },

    //游戏进度
    changeProgress(progress) {
        this.curHp -= progress
        progress  = this.curHp / this.progressHp
        this.gameProgress.progress = progress
        this.progressLabel.string = ''+ parseInt(progress.toFixed(2)*100) +'%'  

        //游戏结束
        if(this.curHp <= 0){
            this.curHp = 0
            game.jGameOver.over(true)
        } 

    },


    // update (dt) {},
});
